package ac.github.os.internal.core.condition.impl.player.interact

import ac.github.os.internal.core.condition.Condition
import ac.github.os.internal.core.config.StringConfig
import ac.github.os.internal.core.config.get
import ac.github.os.internal.core.holder.player.PlayerInteractEntityHolder
import ac.github.os.internal.session.Session
import org.bukkit.entity.LivingEntity
import org.bukkit.event.player.PlayerInteractEntityEvent
import taboolib.common.platform.Awake

abstract class InteractEntityCondition(val name : String) : Condition {
    override fun doScreen(session: Session, config: StringConfig): Boolean {
        val holder = session.holder
        if (holder is PlayerInteractEntityHolder) {
            val event = holder.event
            return this.run(session,config,event)
        }
        return false
    }

    abstract fun run(session: Session,config: StringConfig,event: PlayerInteractEntityEvent) : Boolean

    fun StringConfig.value(def : String? = null) = get("val",single = true, def = def)

    override val namespace: String
        get() = "interact:entity:$name"

}